#include "DoubleLinkedList.h"

/**
DoubleLinkedList<int>::iterator iter;

DoubleLinkedList<int>::iterator find( DoubleLinkedList<int>& _list , int & _val )
{
	iter = _list.begin( );
	while ( iter != _list.end( ) )
	{
		if ( *iter = _val ) return iter;
		else iter++;
	}
}
 */


int main( )
{
	//1、创建链表
	DoubleLinkedList<int> List1( 0 );
	List1.insert( 0, 6, 0 );
	List1.insert( 0, 7, 0 );
	List1.insert( 0, 8, 0 );
	List1.insert( 0, 9, 0 );
	List1.insert( 0, 10, 0 );
	List1.printList( 1 );
    //2、依次插入1,2,3,4,5
	List1.push_back( 1 );
	List1.push_back( 2 );
	List1.push_back( 3 );
	List1.push_back( 4 );
	List1.push_back( 5 );
	//3、输出链表
	List1.printList( 1 );
	//4、查找值为3的元素
    std::cout << "iter的位置为(0表示没找到):" << List1.find( 3 ) + 1 << std::endl;
    //5、删除iter
    List1.erase( List1.find( 3 ), 1 );
    //6、输出链表
	List1.printList( 1 );
    //7、查找值为3的元素
    std::cout << "iter的位置为(0表示没找到):" << List1.find( 3 ) + 1 << std::endl;

	//其他测试
	std::cout << "链表中元素的个数为:" << List1.Size( ) << std::endl;
	List1.push_front( 3 );
	List1.printList( 1 );
	List1.clear( );
	std::cout << "链表为空:" << List1.empty( ) << std::endl;
	return 0;
}
